package com.molichuxing.services.infrastructure.service.impl;

import com.molichuxing.services.infrastructure.convertor.Convert;
import com.molichuxing.services.infrastructure.dao.CarStatisticsMapper;
import com.molichuxing.services.infrastructure.dto.request.create.CarStatisticsCreateDto;
import com.molichuxing.services.infrastructure.dto.response.CarStatisticsDto;
import com.molichuxing.services.infrastructure.service.CarStatisticsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: renzhengyu
 * @Description: 统计实现
 * @Date: Created in 9:50 2019/10/16
 * @Modified By:
 **/
@Service("carStatisticsService")
public class CarStatisticsServiceImpl implements CarStatisticsService {

    @Resource
    private CarStatisticsMapper carStatisticsMapper;


    /**
     * 根据车型id查询车辆统计数据
     * @param vehicleId
     * @return
     */
    @Override
    public CarStatisticsDto getCarStatisticsByVehicleId(Integer vehicleId) {
        return Convert.toCarStatisticsDto(carStatisticsMapper.getCarStatisticsByVehicleId(vehicleId));
    }


    /**
     * 根据车型id查询增加统计数量
     * @param vehicleId
     * @return
     */
    @Override
    public int modifyTradingVolumeByVehicleId(Integer vehicleId) {
        return carStatisticsMapper.modifyTradingVolumeByVehicleId(vehicleId);
    }

    /**
     * 新建统计
     * @param carStatisticsCreateDto
     * @return
     */
    @Override
    public int createCarStatistics(CarStatisticsCreateDto carStatisticsCreateDto) {
        return carStatisticsMapper.create(Convert.toCarStatisticsBean(carStatisticsCreateDto));
    }
}
